"""


"""
from django.conf.urls import url
from rest_framework.routers import DefaultRouter, SimpleRouter
from rest_framework_jwt.views import obtain_jwt_token

from meiduo_admin.views import SPU_views
from meiduo_admin.views import admin_manage_views
from meiduo_admin.views import brand_manage_views
from meiduo_admin.views import channel_manage_views
from meiduo_admin.views import good_options_views
from meiduo_admin.views import good_specs_views
from meiduo_admin.views import group_manage_views
from meiduo_admin.views import home_page_views, user_views, SKU_views
from meiduo_admin.views import image_views
from meiduo_admin.views import order_view
from meiduo_admin.views import permission_manage_views

urlpatterns = [

    # TODO --------------------首页栏目
    url(r'^authorizations/$', obtain_jwt_token),
    url(r'^statistical/total_count/$', home_page_views.TotalCountView.as_view()),
    url(r'^statistical/day_increment/$', home_page_views.IncrementCountView.as_view()),
    url(r'^statistical/day_active/$', home_page_views.DayLoginCountView.as_view()),
    url(r'^statistical/day_orders/$', home_page_views.DayOrderCountView.as_view()),
    url(r'^statistical/month_increment/$', home_page_views.MonthIncrementCountView.as_view()),

    # 获取商品的访问量
    url(r'^statistical/goods_day_views/$', home_page_views.GoodDayView.as_view()),

    # TODO --------------------用户栏目
    # 用户
    url(r'^users/$', user_views.UserListView.as_view()),

    # TODO --------------------SKU分类栏目
    # 获取sku数据
    # url(r'skus/$', views.SKUListView.as_view()),

    # 获取sku分类
    url(r'^skus/categories/$', SKU_views.SKUCategoryView.as_view()),

    #TODO --------------------SPU分类栏目
    # 获取spu分类
    url(r'^goods/simple/$', SKU_views.SPUCategoryView.as_view()),

    # 获取spu规格以及信息
    url(r'^goods/(?P<pk>\d+)/specs/$', SKU_views.SPUSpecs.as_view()),

    # 获取品牌信息
    url(r'^goods/brands/simple/$', SPU_views.SPUListView.as_view({"get": "brand"})),
    url(r'^goods/channel/categories/$', SPU_views.SPUListView.as_view({"get": "categories"})),
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', SPU_views.SPUListView.as_view({"get": "sub_categories"})),
    url(r'^goods/images/$', SPU_views.SPUListView.as_view({"post": "images_uploader"})),

    # TODO 规格管理栏目
    # url(r'goods/specs/$', good_specs_views.GoodSpecsView.as_view()),
    # url(r'goods/specs/(?P<pk>\d+)/$', good_specs_views.ChangeGoodSpecsView.as_view()),

    # TODO 规格选项管理
    url(r'^goods/specs/simple/$', good_options_views.GoodOptionsViewSet.as_view({"get": "good_specs"})),

    # TODO 图片管理栏目
    url(r'^skus/images/$', image_views.SKUImageView.as_view({"get": "list", "post": "image_uploader"})),
    url(r'^skus/simple/$', image_views.SKUImageView.as_view({"get": "SKU_simple"})),
    url(r'^skus/images/(?P<pk>\d+)/$', image_views.SKUImageView.as_view({"get": "retrieve",
                                                                         "put": "update",
                                                                         "delete": "destroy"})),

    # TODO 订单管理视图集
    url(r'^orders/$', order_view.OrderView.as_view()),
    url(r'^orders/(?P<pk>\d+)/$', order_view.OrderDetailView.as_view()),
    url(r'^orders/(?P<pk>\d+)/status/$', order_view.OrderStatusView.as_view()),

    # 用户权限的管理页面
    url(r'^permission/content_types/$', permission_manage_views.ContentTypeView.as_view()),
    url(r'^permission/simple/$', group_manage_views.PermissionSimpleView.as_view()),


    # TODO 管理员界面
    url(r'permission/groups/simple/$', admin_manage_views.GroupSimpleView.as_view()),


]

# TODO goods/brands/ 品牌管理

router = DefaultRouter()

router.register(r'goods/brands', brand_manage_views.BrandManageView, base_name='brand')

urlpatterns += router.urls


# TODO goods/channels/ 频道管理
router = DefaultRouter()

router.register(r'goods/channels', channel_manage_views.ChannelManageView, base_name='channel')

urlpatterns += router.urls


# TODO permission/admins/ 管理员管理
router = DefaultRouter()

router.register(r'permission/admins', admin_manage_views.AdminManageView, base_name='admin')

urlpatterns += router.urls

# TODO 用户组管理
router = DefaultRouter()

router.register(r'permission/groups', group_manage_views.GroupManageView, base_name='group')

urlpatterns += router.urls


# TODO 权限管理页面

router = DefaultRouter()

router.register(r'permission/perms', permission_manage_views.PermissionManageView, base_name='permission')

urlpatterns += router.urls


# TODO 规格管理栏目,这个一定要写在goods的前面，不然会被吃掉
#1,创建路由
router = DefaultRouter()
#2,注册视图集
router.register(r'goods/specs',good_specs_views.GoodSpecsViewSet,base_name="specs")
#3,添加路由到urlpatterns
urlpatterns += router.urls

# 商品的sku栏目
router = DefaultRouter()

router.register('skus', SKU_views.SKUListView, base_name="sku_info")

urlpatterns += router.urls

# 商品的spu栏目
router = DefaultRouter()

router.register(r'goods', SPU_views.SPUListView, base_name='spu_info')

urlpatterns += router.urls


# 商品的规格栏目
# router = DefaultRouter()
#
# router.register('^goods/specs', good_specs_views.GoodSpecsViewSet, base_name='good_specs')
#
# urlpatterns += router.urls
#
# for temp in urlpatterns:
#     print(temp)

# TODO 规格选项管理
router = DefaultRouter()

# router.register('^specs\options', good_options_views.GoodOptionsViewSet, base_name='options')
router.register(r'specs/options', good_options_views.GoodOptionsViewSet, base_name="specs")

urlpatterns += router.urls


# TODO 图片管理栏目




